// 文件大小转化(根据字节大小，返回合适的后缀、大小【KB、MB、GB】)
export default function formatFileSize(size) {
  let num = Number(size);
  num = isNaN(num) ? 0 : num;
  if (num < (1024)) {
    return size + 'B';
  } else if (num < (1024 * 1024)) {
    return (num / 1024).toFixed(2) + 'KB';
  } else if (num < (1024 * 1024 * 1024)) {
    return (num / (1024 * 1024)).toFixed(2) + 'MB';
  } else {
    return (num / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
  }
}
